es6 features

New Features in ES6 / ECMAScript 2015

Posted Leave a commentPosted in JavaScript, Technology

We are going to take a look at the new ES6 Features, mainly the important ones. 1. Default Parameters Earlier way var calculate = function(x, y) { x = x || 10; } ES6 way var calculate = function(x = 10, y) { … } 2. Template Literals Earlier version of string interpolations var name = ‘Name is ‘ + firstName + ‘ ‘ + lastName; ES6 Way (usage of back-ticks) var name = `Name is ${firstName} ${lastName}` 3. Multi-line strings Earlier way var text = ‘This is the first line \n’ + ‘This is the second line.’; ES6 way  … [Read More]

javascript

JavaScript: Working with Array

Posted Leave a commentPosted in JavaScript, Technology

Defining an array var arr = [1, 2];var arr1 = new Array(1,2); var arr2 = new Array(length); // This will create an array of the given length, but won’t initialize the values. The values would be empty and not undefined. Looping through Array arr.forEach((item, index, array) => {     // item => the current item     // index => index of the current item     // array => the actual array passed }); Retrieving an item from array arr[2]; // This will return 3rd element in the arrayarr[2] = arr[02] = arr[‘2′] != arr[’02’]arr.indexOf(2); // Returns the index of the item, or -1  … [Read More]

javascript

Algorithms in JavaScript

Posted Leave a commentPosted in JavaScript, Technology

SECTION 1 – Introduction Introduction to AlgorithmsAlgorithms make programs run better and faster. SECTION 2 -FizzBuzz IntroductionA function that will take a number and log all the numbers from 1 till that given number.Additionally, if the number to be logged is divisible by 3, then log ‘Fizz’, if divisible by 5, then log ‘Buzz’ and if by both 3 & 5, then log ‘FizzBuzz’ Modulus Operator – It returns the remainder of a division. Code function fizzBuzz(num) {    for (var i = 1; i<= num; i++) {        if (i % 3 === 0 && i % 5 === 0) {  … [Read More]

javascript

Data Structures in JavaScript

Posted Leave a commentPosted in JavaScript, Learning, Technology

1. What are Data Structures and why are they ImportantData Structures are way of organizing data that is stored in a computer or database. Each type of data structure represents a different way of organizing the data.There are different types of data structures because they have different strengths and weaknesses.Some are fast at storing and slow at retrieving and some vice-versa. Importance of Data Structures:– Data structures have big impact on performance, quick and efficiently a program runs. Example, when we need to store data at a faster pace, we can use linked list. Or when we need to access  … [Read More]

javascript

Understanding the Weird Parts of JavaScript

Posted Leave a commentPosted in JavaScript, Learning, Technology

SECTION 1 – Getting Started 1 – Introduction and the Goal of the CourseThe goal is to understand how JavaScript works under the hood.2 – Setup3 – Big Words and JavaScript4 – Watching this Course in High-Definition5 – Understanding Frameworks and the Weird Parts SECTION 2 – Execution Contexts and Lexical Environments 6 – Conceptual Aside: Syntax Parsers, Execution Contexts and Lexical EnvironmentsSyntax parser – A program that reads the code and determines what it does and if it’s grammar is valid – Is done character by characterLexical Environment – Where something sits physically in the code that is writen.Execution  … [Read More]

html javascript

Advanced JavaScript v1

Posted Leave a commentPosted in JavaScript, Learning

“use strict”; // needs to be used as string as most browsers didn’t used to support this and so would throw error. 2: We can use the Chrome Developer Tools Snippets to develop small pieces of code. “use strict”; or someFunction() { “use strict”; … } strict mode checking works ont eh scope it is declared in. Issues with non strict mode var theVal = 0; thVal = 1; // spelling mistake wouldn’t be caught in non-strict mode if (theVal > 0) { console.log(‘Hello’) } Uses: 1. Precents accidental global vartiable declarations. 2. Prevents using reserved keywords. 3. Prevents deleting  … [Read More]