However, this code runs perfectly fine without producing any errors.But if we run this in strict mode,"use strict"; function person(name) { this.name = name; } let fuzzy = person("Fuzzy"); OutputTypeError: Cannot set property of 'name' undefined. Strict mode disallows giving a function...
Task: Let's try above code and try to change value of score at end of the program and print it, see what happens.Yes, you will receive an error, again this is because const cannot be changed.You might be thinking then why to use const when you cannot change its value....
Here is this snippets output:We learned two things how to create an object and methods in objects now we will discuss how a function can be used to manipulate an object, let's see in next code snippet.let myArticle = { articleName: 'Objects in Javascript', author: 'Himanshu', ...
In this JavaScript code, we added items into the local Storage using localStorage.setItem(key, value), this setItem() method accept two parameters one key and other its value both in String format.Now to retrieve those values from the local storage we will be using localStorage.getItem(key),...