Teaching Newbies since 2014

  • Home
  • Javascript ❤
    • JavaScript
    • Node.js
  • WebDev Tuts
  • screencasts
  • Resources
  • VR & AR
  • Github
  • Twitter
  • YouTube
  • RSS
  • C++
You are here: Home / Archives for Javascript ❤

August 21, 2020 by: Kauress

Getters & Setters in JavaScript – part 2

carrying on from part 1 .. Getters in JavaScript Getters are functions that retrieve a value from static properties from an external source. You can only access properties and cannot access methods as they are functions of an object or class and are not static.There are three ways you can use getters and setters:1. Default method syntax2. get  keyword3. Object.defineProperty() method We will now discuss

[ Read More ]

August 20, 2020 by: Kauress

Classes in JavaScript – a newbie friendly introduction

Classes In object-oriented programming, class types are templates for creating objects. As we justlearned that in prototypal inheritance, objects inherit properties and methods from aprototype. Classes build upon prototypal inheritance. Classes were introduced in ES6 tomimic the class data type found in Java and other object-oriented programming languages. Till now developers used constructor functions to mimic object-oriented design patterns.JavaScript does not have the class type,

[ Read More ]

August 19, 2020 by: Kauress

Setters and Getters in JavaScript – part 1

Accessors: Getters and Setters This is part 1  of a brief introduction to getters and setters in JavaScript. Getters and Setters are ES5 features. Objects have two types of properties: Static data property Accessor property So far we have come across static data properties in the objects that we have been making. For example: let blackLivesMatter = { status: true, usecase: ‘daily’ } In this

[ Read More ]

August 18, 2020 by: Kauress

The break and continue statements in JavaScript

Break and continue statements The break statement is used to exit a loop completely once a condition has been met, or after x number of iterations. As such it is commonly used within an if conditional block. Take as an example the following code: for (let i = 0; i <= 5; i++){ console.log(i); } This will print out the value of variable i from

[ Read More ]

August 17, 2020 by: Kauress

Deep & shallow copying in JavaScript – part 3

Copying objects with deep copy The JSON.stringify and JSON.parse methods can be used to deep copy an object. In a deep copy, the source and target objects have different memory addresses and are not connected at all. The JSON.stringify() method will take a JavaScript object as an argument and transform it into a string. Then the JSON.parse() method will parse the JavaScript string and return

[ Read More ]

August 16, 2020 by: Kauress

Deep and shallow copying in JavaScript – part 2

 Copying objects with Shallow copy Now that we went over shallow and deep copies in part 1, let’s go over shallow copying in JavaScript. There are 3 ways to create shallow copies in JavaScript: Iteration using for key in an object Spread operator Object.assign() 1. Iteration using for key in an object In order to copy the items of an object into another object we

[ Read More ]

August 15, 2020 by: Kauress

Deep and shallow copying in JavaScript – part 1

Copying objects with shallow and deep copies Primitive values such as strings, and numbers are copied by value, whereas objects are copied by reference. What do we mean by this? The following code example will explain this practically: let num1 = 10; let num2 = num1; num1 = 6; console.log(num2); //10 The value of num1 which is the number 10 is assigned to the variable

[ Read More ]

August 14, 2020 by: Kauress

Pass by reference vs Pass by Value

Pass by value Non-primitive data types are passed by reference compared to primitive data types that are passed by value. As such non-primitive data types are also called reference types. To understand why they’re called reference types, we need to briefly look at how variables are stored in memory. A fixed amount of memory is allocated to a variable after it is declared. For primitive

[ Read More ]

August 12, 2020 by: Kauress

Execution context in JavaScript for beginners

Introduction Execution context is an abstract concept describing the environment within which JavaScript code is executed. The execution context will dictate if a variable, object, or another block of code is accessible or not. There are two types of execution contexts: global and function. Let’s examine the global execution context first. Global execution context The global execution context is the default execution context. Variables and

[ Read More ]

August 10, 2020 by: Kauress

What is the event loop anyways?

Introduction JavaScript is single-threaded this means that the main thread on which code is executed runs one line at a time. There is no possibility of doing anything in parallel. Therefore, the run time is blocked until a task is completed. An example of blocking the run time is an infinite loop. However, the DOM API, setTimeout() , setInterval() methods are provided by the web

[ Read More ]
  • « Previous Page
  • 1
  • 2
  • 3
  • 4
  • …
  • 8
  • Next Page »

Copyright © 2022 ·Kauress