Skip to main content

Posts

Showing posts with the label Difference between == and === in JavaScript

JavaScript Let vs Var - When should let be used over var?

Let Keyword - The “ let ” keyword declares a block-scoped variable. Let and var declared outside any block, both are global. The “ let ” keyword allows you to declare a variable that are limited in scope to the block, statement, or expression on which it’s used. You can assign values to the variables when you declare them or later in your script. If you do not initialize your variable in the “ let ” statement, it is automatically assigned the JavaScript value. Let variables cannot be re-declared while var variable can be re-declared in the same scope. A variable declared by “ let ” can’t be used before its declaration or an error will result. A variable declaration with “ let ” is helpful when we want the scope of a variable to be limited to statement or expression level. Let gives you the privilege to declare variables that are limited in scope to the block, statement of expression unlike var. The “let” statement declares a local variable in a block sco...

How To open URL in new tab in JavaScript?

JavaScript Open URL in New Tab - The “window.open()” function is used to open the URL tab in JavaScript. Example- window . open ( 'http://code-sample.com/' , '_blank' ); ü   Stayed Informed –   Object Oriented JavaScript Interview Questions I hope you are enjoying with this post! Please share with you friends!! Thank you!!!

How To Convert a string to Lowercase?

To convert a string to lowercase -  To convert a string in JavaScript using the “toLowerCase()” method. The string length should be grater then zero. Example - let testStr = 'This is test string' ; testStr = testStr . toLowerCase (); console . log ( testStr ); //Output - This is test string ü   Stayed Informed –   Object Oriented JavaScript Interview Questions I hope you are enjoying with this post! Please share with you friends!! Thank you!!!

5 Best ways to empty an array in JavaScript [How To]

How to empty an array in JavaScript? var userList =  ['anil','kumar','singh','kushinagar','up','india']; Answers:- Method 1 : - userList =[]; Method 2 : - userList.length=0; Method 3 : - userList.splice(0, userList.length); Method 4 : - while (userList.length > 0) {     arrayList.pop(); } I am not recommended to use "method 4". You can use “method 2” and “method 3” because it is so fast. Stayed Informed – Best JavaScript Interview Questions & Answers I hope you are enjoying with this post! Please share with you friends. Thank you!!

What is DOJO toolkit?

DOJO is a rapid development toolkit for web oriented software on desktop and mobile and internet applications without using the browser’s inbuilt graphics technology.  DOJO is being used by all the popular internet browsers like Internet Explorer, Google Chrome, Safari, Firefox, and Opera and on smart phones and tablets by Apple (iPhone, iPod) Google (Android) and BlackBerry. DOJO provides us many widgets , utilities and AJAX libraries to develop our applications. DOJO provides the connection between DOM element and DOJO function and also contains many DOM elements looks like, 1.       HTML, 2.       SVG and 3.       Style packages. DOJO is helping us to create rich and interactive web applications and it is similar like Comet and Ajax . Dojo has great support for integrating with back end data store. It works seamlessly with REST services . We even extended Dojo's J...

0x80070005 - JavaScript runtime error: Access is denied.

The error prompt looks like below pic. Are you using HTML 5’s locaStorage or sessionStorage ? If yes that is the reason for IE browser. The solution is that go to,                     I.             Internet Options                   II.             Security and                 III.             Uncheck EnableProtectedMode                 IV.             Refresh your browser and try to run. It is also happing when, ...

parseInt() vs. parseFloat() in JavaScript

Dear Friends, Today we are going to discuss about the following topics. 1.       What is meant by parseInt, when it will be used? 2.       What is meant by parseFloat, when in will be used? Whenever we are capturing any number value in HTML forms, by default it will be number. So to do any mathematical it needs to be converted.  With can convert any string in to number with parseInt(), which is an inbuilt JavaScript method. But, this parseInt() Method will be used if we are dealing with integer values only. Since it won’t recognize the Floating values like 10.73, 11.77, 3.44… In such cases we use parseFloat() Method. Let me explain this with an Example as follows. Lest us create simple HTML form like follows. In this Example we will be having 3 input fields. First two input fields will be firstNumber and lastNumber respectively. Once user enter first number and second number and click ...

Get Client IP Address using JavaScript and JSON

In this post, there are 2 online services which allow us to get client IP address . This is free resources and for more information’s about this. 1.       jsonip.com 2.       Smart-IP.net //Using jsonip.com $ .getJSON( "https://jsonip.com?callback=?" , function (data) { alert ( "Your IP address is :- " + data.ip); }); //Using Smart-IP.net $ .getJSON( 'http://smart-ip.net/geoip-json?callback=?' , function (data) { alert ( "Your IP address is :- " + data. host ); }); Example, < ! DOCTYPE html > < html > < head > < meta charset = "utf-8" / > < title > Get Client Machine IP Address using JavaScript and JSON < /title > < link rel = "stylesheet" href = "style.css" / > < script src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js" > < /script > < script type = "text/javascript" ...

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:- ...