Basics of JavaScript Archives - {coding}Sight https://codingsight.com/category/languages-coding/basics-of-javascript/ Blog for SQL Server DBAs and Developers Fri, 07 Oct 2022 07:32:12 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 https://codingsight.com/wp-content/uploads/2021/10/cropped-Soсial_-Fb_180х180-1-32x32.png Basics of JavaScript Archives - {coding}Sight https://codingsight.com/category/languages-coding/basics-of-javascript/ 32 32 JavaScript Recipes: A Problem-Solution Article https://codingsight.com/javascript-recipes-a-problem-solution-article/ Tue, 05 Apr 2016 09:37:22 +0000 http://codingsight.com/?p=153 Why reinvent the wheel every time you run into a problem with JS? This article is chock-full of code recipes that address common programming tasks. Q: What is Javascript object creation best practice? How to protect themselves from errors, if the new keyword is used? I always capitalize constructor names. I use this instanceof funcName to validate …

The post JavaScript Recipes: A Problem-Solution Article appeared first on {coding}Sight.

]]>
Javascript Closures https://codingsight.com/javascript-closures/ Tue, 05 Apr 2016 09:09:50 +0000 http://codingsight.com/?p=149 Closures in Javascript are (internal or nested) functions that refer to (outer) independent variables. Simply put, the function declared in the closure remembers the environment in which it was created. Lexical scope Consider the following: function outerFunc() { var outerVar; var func = function () { var innerVar //Do something here x = innerVar + …

The post Javascript Closures appeared first on {coding}Sight.

]]>
Javascrtipt Deep Copy https://codingsight.com/javascrtipt-deep-copy/ Tue, 05 Apr 2016 09:05:40 +0000 http://codingsight.com/?p=147 In this article, we will discuss how to copy and deep copy javascript objects. Simple copying of a javascript object The following function copies all properties of an existing object. It takes an object as an argument and returns a new copy of that object. function extendCopy(p) { var c = {}; for (var i …

The post Javascrtipt Deep Copy appeared first on {coding}Sight.

]]>
Creating Excel in JavaScript https://codingsight.com/creating-excel-in-javascript/ Tue, 05 Apr 2016 08:56:19 +0000 http://codingsight.com/?p=145 In this article, we will create an excel-like application that takes about 30 rows of JS code, with automatic saving to localStorage. No third party libraries are used. To create a formula, you can use “=”. You can also create arbitrary expressions like (=A1+B2*C3) and detect circular references. HTML <table> </table> CSS input { border: none; width: 80px; font-size: …

The post Creating Excel in JavaScript appeared first on {coding}Sight.

]]>
Detecting Internet Explorer in JavaScript https://codingsight.com/detecting-internet-explorer-in-javascript/ Mon, 11 Jan 2016 08:52:38 +0000 http://codingsight.com/?p=143 There are several simple ways to detect whether the web browser is IE or not. In the following code example, the variable returns true in Internet Explorer and false in all other browsers. This is possible because of an IE bug. var ie = !-1, ; alert(ie); This option does not depend on the display …

The post Detecting Internet Explorer in JavaScript appeared first on {coding}Sight.

]]>
Iterating Over JavaScript Arrays https://codingsight.com/iterating-over-javascript-arrays/ Thu, 22 Jan 2015 09:13:59 +0000 http://codingsight.com/?p=151 Iterating Over Arrays The article describes ES5 and ES6 approaches to iterate over javascript arrays and array-like objects! There are three ways to iterate through an array: The Array.prototype.forEach method; The for loop; The for..in statement. Additionally, two new methods are expected with the introduction of the new ECMAScript 6 standard: The for…of statement; The …

The post Iterating Over JavaScript Arrays appeared first on {coding}Sight.

]]>