Note: If this tutorial was helpful, need further clarification, something is not working or do you have a request for another Ionic post? Furthermore, if you don't like something about this blog, if something is bugging you, don't like how I'm doing stuff here, again leave me a comment below. I'm here to help you, I expect the same from you. Feel free to comment below, subscribe to my blog, mail me to dragan.gaic@gmail.com, or follow and mention me on twitter (@gajotres). Thanks and have a nice day!
PS. If you want my help, if possible (even if it takes you some time to do that), create a working example I can play with. Use Plunker for AngularJS based questions or jsFiddle for jQuery/jQuery Mobile based questions.
PS. If you want my help, if possible (even if it takes you some time to do that), create a working example I can play with. Use Plunker for AngularJS based questions or jsFiddle for jQuery/jQuery Mobile based questions.
1
What is JavaScript, what about history?
2
How's JavaScript related to Java and JScript?
var a = parseInt("10");
int x = Integer.parseInt("9");
3
Enumerate different groups of data types used in JavaScript?
4
What is the use of the Typeof operator?
typeof 14 === 'number'; typeof "bla" === 'string'; typeof true === 'boolean'; typeof Symbol() === 'symbol' typeof undefined === 'undefined'; typeof {foo:bar} === 'object'; typeof [1, 2, 3] === 'object'; typeof new Date() === 'object'; typeof function(){} === 'function'; typeof null === 'object';
5
Enumerate different data types used in JavaScript?
- String
- Number
- Symbol (new in ECMAScript 2015)
- Boolean
- Function
- Object
- Null
- Undefined
6
Do we need to care about JavaScript data type conversions?
1 + 2 + "3" // will give 33 1 + 2 + +"3" // will give 6 "1" + 2 + 3 // will give 123 +"1" + 2 + 3 // will give 6
var s = '5'; console.log(s); // will return 5, Typeof string var a = s*1; console.log(a); // will return 5, Typeof number var b = +s; console.log(b); // will return 5, Typeof number
7
Name any JavaScript function used for data conversion?
parseFloat(); String to floating point number
parseInt(); String to integer
String(); Object to string
8
How can we comment code in JavaScript?
// var s = '5';
/* var s = '5'; console.log(s); */
9
What is the use of isNaN() and isFinite()?
console.log(isNaN("123")); // will return false console.log(isNaN("Hello")); // will return true
console.log(isNaN("123")); // will return true console.log(isNaN("Hello")); // will return false
10
What is the use of eval() and why is it dangerous?
console.log(eval("2 + 2")); // will return 4
11
What are the decodeURI() and encodeURI() methods?
var uri="https://www.google.hr/?gws_rd=ssl&error=Some stupid error"; console.log(encodeURI(uri)); // will output: https://www.google.hr/?gws_rd=ssl&error=Some%20stupid%20error console.log(decodeURI(uri)); // will output: https://www.google.hr/?gws_rd=ssl&error=Some stupid error
12
Define unescape() and escape() methods?
console.log(escape("This string needs some 'decoding'")); // will output: This%20string%20needs%20some%20%27decoding%27 console.log(unescape("This%20string%20needs%20some%20%27decoding%27")); // will output: This string needs some 'decoding'
13
What are escape characters?
console.log('This is a \'special\' route'); // will output: This is a 'special' route
14
Can we brake JavaScript code into several lines?
var foo=1, bar= foo + 2; console.log(bar); // will output 3
15
What is Scope in JavaScript?
var a = 1; function one() { alert(a); // Will alert 1 }
var a = 1; function someFunction(a) { alert(a); // Will alert 1 } function otherFunction() { var a = 2; alert(a); // Will alert 2 }
16
Is JavaScript a pass-by-reference or pass-by-value language?
function testArguments(primitive, obj1, obj2) { primitive = primitive * 10; obj1.item = "changed"; obj2 = {item: "changed"}; } var primitive = 10; var obj1 = {item: "unchanged"}; var obj2 = {item: "unchanged"}; testArguments(primitive, obj1, obj2); console.log(primitive); // will return 10 console.log(obj1.item); // will return changed console.log(obj2.item); // will return unchanged
17
What is variable and function hoisting in JavaScript?
var myvar = 'my value'; (function() { alert(myvar); // undefined var myvar = 'local value'; })();
// Outputs: "Yes!" isItHoisted(); function isItHoisted() { console.log("Yes!"); }
var foo; //declaration foo = "bar"; // initialization var foo; // Another declaration of foo is hoisted and the value is set to undefined. foo = "bar"; // The value is now again "bar") function getFoo() { var foo; // Another declaration of foo is hoisted and the value is set to undefined. console.log(foo); // will return undefined foo = "bar"; console.log(foo); // The output is "bar" }
18
What are global (globaly scoped) variables?
globalVar= 'Heh'; // Global variable function someFunction() { var localVar= 'Meh'; // Local variable }
19
What would happen if we don't declare a variable in Javascript?
function testDeclarations(){ primitive1 = 1; var primitive2 = 2; console.log("The first number:"+primitive1+" <--> The second number:"+primitive2); // will output: The first number:1 <--> The second number:2 primitive2 = 3; console.log("The first number:"+primitive1+" <--> The second number:"+primitive2); // will output: The first number:1 <--> The second number:3 }; primitive1 = 44; testDeclarations(); console.log("The first number:"+primitive1); // will output: The first number:1 console.log("The second number:"+primitive2); // will output: Uncaught ReferenceError: primitive2 is not defined
Continue Reading