Javascript interview questions with answers
What are the advantages of using JSON rather than using xml
JSON is a lightweight format for storing and transferring data. When compared to xml, json files are of lesser size for the same amount of data as it doesnt need the extra tags as required by xml. Also, json is widely used in various languages.
Difference between Javascript Object and JSON format
There are 3 fundamental differences between Javascript Object and JSON format. They are
- Keys should be enclosed in double quotes in JSON, but its not mandatory in javascript objects.
- Javascript objects can have functions as value, whereas JSON may not contain functions.
- The last value in a javascript object can have a trailing comma ‘,’, but in JSON its not the case (this is a structural difference only)
Difference between var and let
var
can be redeclared within {}, but let
cannot be redeclared.
100var a = "my string";
101var a = 5;// Does not throw error
102
103let a = "my string";
104let a = 5;// Uncaught SyntaxError: Identifier 'a' has already been declared
While var
has function scope, let
has block scope.
100for(var i=10; i<20; i++) {
101 //do something
102}
103
104console.log(i) // prints i as 20
105
106for(let j=10; j<20; j++) {
107 //do something
108}
109console.log(j) //j is not defined error
Related Posts
How to maintain multiple versions of django without using using virtual envs.
Most linux come installed with python 2.7. Some even come installed with both 2.7 and 3 as well. django upto version 1.
Read moreRegex Cheatsheet
We have compiled a list of regular expression cheatbook to help in learning regular expressions. This is categorized into multiple sections for easy understanding.
Read moreTypes of Web Hosting
The internet is emerging fast and big and today we have a variety of options to host our website than we had earlier.
Read more