Skip to main content

Posts

Showing posts with the label Create Image Slider JavaScript

What is the difference between the function declarations below?

What is the difference between the function declarations below? var user = function () { //TODO: Some code }; And function country() { //TODO: Some code }; Answers :- The main difference is the function user is defined at run-time whereas function country is defined at parse time. For example as, < script type = "text/javascript" > //WHEN WE CALLING USER FUNCTION HERE WILL THROW AN ERROR. user(); var user = function (){ alert( "Hello, I am a user!" ); }; < /script> < script type = "text/javascript" > //WHEN WE CALLING USER FUNCTION HERE WILL NOT THROW AN ERROR. country(); function country(){ alert( "Hello, I am a country!" ); }; < /script> Stayed Informed – Best JavaScript Interview Questions & Answers I hope you are enjoying with this post! Please share with you friends. Thank you!!

MVC Anti forgery for HTTP Headers validator

/ / WEB API ANTIFORGERY CUSTOM ACTION FILTER ATTRIBUTE public class AntiForgeryValidateRequests : BaseActionFilterAttribute { public override void OnActionExecuting(HttpActionContext filterContext) { if (filterContext ! = null & & filterContext.RequestContext ! = null & & filterContext.Request ! = null ) { string cookieToken = "" ; string formToken = "" ; IEnumerable < string > tokenHeaders = filterContext.Request.Headers.GetValues( Constant .RequestVerificationToken); if (tokenHeaders ! = null & & tokenHeaders. Count () > 0 ) { string [] tokens = tokenHeaders. First ().Split(':'); if (tokens. Length = = 2 ) { cookieToken = tokens[ 0 ].Trim(); formToken = tokens[ 1 ].Trim(); } } System.Web...

How to Create a Simple Image Slider in JavaScript?

Dear Friends, In this Article i am going to explain about creating a simple slider in JavaScript. So let us start step by Step tutorial on How to create a simple image slider in JavaScript.  Before starting this Example you should know the following topics. What is JavaScript Arrays & How to Populate arrays in JavaScript? What is meant by Set Interval and Clear Interval in JavaScript? How to change image source dynamically with JavaScript? If you are not clear about the above mentioned topics, I strongly suggest you to please go through the above mentioned topics first. If you know above topics, let is start the example. Step 1:- Create a simple HTML Template as Follows with Image element with id " myImg " in it. < ! DOCTYPE html > < html > < head > < title > < /title > < /head > < body > < img src = "" id = "myImg" > < /body > < /html > Step 2:- ...

How do you define a class and its constructor?

A JavaScript Constructor is a function which is used as a constructor that allows you to create an object from a class. A constructor access is one of public, protected and private. Three ways to define a JavaScript class , 1.       Using as a function 2.       Using as Object Literals 3.       Singleton using as a function Stayed Informed - Why “ self ” is needed instead of “ this ” in JavaScript? The Syntax access NameOfAClass(parameters) { initialization code; } //Access as public public customer(parameters) { initialization code; } //Access as protected protected customer(parameters) { initialization code; } //Access as private private customer(parameters) { initialization code; } Examples as , //class declaration inJavaScript //constructor var customer = function (id, name, age) { } customer . prototype = {} //Instance variables members. va...

What is ‘this’ in JavaScript?

Hello everyone, today's I am going to share a basic and very confusing concepts that is called 'this' keyword :) The  'this' keyword  behaves a little differently in  JavaScript  compared to other languages. In most of the other languages, ' this ' keyword is a reference to the current object instantiated by the classes  and methods.  In the JavaScript  languages , 'this' keyword refers to the object which 'owns' the method, but it depends on how a function is called. The examples in details as given below. //Global Scope in JavaScript //In the below example, ‘this’ keyword refers to the global object. window .sms = "Hi, I am window object" ; console .log ( window .sms); console .log (this.sms); // Hi, I am window object. console .log ( window === this); // Its return true. //Calling a Function in JavaScript //In the below example, ‘this’ keyword remains the global object if we are calling a function. wi...

difference between == and === in JavaScript

In this post, I am going to share the very interesting double equals  " =="   and   triple equals "=== ". It is  very confusing topic and most of the time peoples are confused. The details  example as given below. The double equals (==) are used for check only value of its variables but triple equals (===) are used for check value and type as well of its variables. 1.   The double equal “==” is an  auto-type  conversion  and it checks only value not type. 2.    The triple equal “===” is not auto-type conversion  and it check value and type both. For example, < ! DOCTYPE html > < html > < head > < meta charset = "utf-8" / > < title > Difference between == and === in JavaScript < /title > < script src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js" > < /script > < script > // alert(0 == false);...