Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Scope



  Name resolution order in JavaScript

To understand what value a variable has in JavaScript, we need to understand some concepts such as scope and name resolution order. JavaScript has two scopes; one is program level and the other one is function level. Unlike in C,C++ or Java, JavaScript has no block level scope. So a variable defined in a if block will still be available outside. For example, the below example: var foo = 1; function bar() { if (true) { var foo = 10; } alert(foo); } bar(); The alert will display 10 since the ...

   JavaScript,Scope,Name resolution     2013-07-10 01:29:28

  Strict mode in JavaScript

1. Introduction In addition to normal mode, ECMAScript 5 includes the other mode : strict mode. It means it will make JavaScript codes execute in a more strict environment. The purposes to have strict mode are: Remove some unreasonable and parts of JavaScript syntax. Reduce some of the quirk behaviors. Remove some insecure parts of code execution. Make the execution environment more secure Improve interpret efficiency and increase the execution speed Build foundation for future JavaScript versi...

   JavaScript, Strict mode. Introduction     2013-01-17 05:00:26

  var in JavaScript

Geoff published an article sometime ago--"How one missing var ruined our launch". This article described one case where MelonCard uses Node.js as their backend system, suddenly there was a small registration peak period--50-100 people registered concurrently, then the entire website stopped responding and many other strange problems showed up. When they were investigating the source of the problem, they found one missing var in the following code.app.all(‘/apps/:user_id/status’, fun...

   JavaScript,Scope,variable     2012-05-26 12:35:36

  JavaScript: Private variables

The first thing you often hear when talking about JavaScript is often “JavaScript doesn’t have visibility modifiers, hence it doesn’t support private variables”. This is only valid for 50%, because JavaScript indeed doesn’t have visibility modifiers (public, private, friend) but it has closures and function scopes. With these tools we can make variables private. Let’s take the following function: var names = ["Kenneth", "John", "Marc", "Robert"]; var lookup =...

   JavaScript,private variable,closure     2012-04-28 11:46:34

  Understanding JavaScript closure and where it can be used

Closure The official definition of closure is: an expression (usually a function) that has many variables and is bound to an environment that includes those variables. In JavaScript, closure refers to the ability of a function to access the lexical scope in which it was defined, even after the function has been executed and left that scope. This ability is due to the fact that when a function is created, it generates a closure that includes a reference to the definition environment of the curr...

   CLOSURE,JAVASCRIPT,USAGE     2023-03-05 02:17:08

  Stanford Computer Science '10-'11 Salary Survey Results

CS/EE UndergradsData: I received 140 responses which described 360 job offers. 95% of the job offers were primarily located in the Bay Area, 5% were from the Midwest and East Coast. 10% of the job offers were from start-ups.Salary offers ranged from $64,400 to $100,000. The average salary offer was $79,914. The median salary offer was $ 82,200.About 70% of students were offered stock options. About 80% of students were offered signing bonuses. And about 60% were offered relocation assistan...

   Stanford,Computer science,Salary,Survey     2011-12-25 00:54:41

  this in JavaScript in detail

this in JavaScript is always confusing, it is one of the most frequently seen traps in JavaScript. this is not a good design in JavaScript(You can refer some other design flaws of JavaScript here), since it's lazy binding feature, it can be a global object, the current object or.... Some people even avoid using this in JavaScript. Actually if you master how this works, then you will know how to stay away from these traps. Let's take a look at what this points to in below situations. 1. In global...

   JavaScript,this,bind     2013-05-09 18:35:12

  4 ways to obtain access token in OAuth 2.0

OAuth 2.0 is an authorization mechanism, it's ,mainly used for issuing access token. There are 4 ways to obtain access token as per RFC 6749. Authorization code Implicit Password Client credentials The third party application must obtain a client id and client secret from the target service before obtaining access token no matter which method to use. This is to prevent token to be used maliciously. Authorization code With this method, the third party application must first get an authorization...

   OAUTH2,ACCESS TOKEN,REFRESH TOKEN     2019-06-29 07:12:03

  Alibaba CEO Daniel Zhang is no longer president of Taobao Software Co. Ltd

According to a recent change record from Chinese company registration information portal, the Chinese e-commerce giant Alibaba Group CEO Daniel Zhang is no longer the president of TaoBao Software Co. Ltd. His successor is Shan Dai, who is one of the founders of Alibaba and now Taobao CEO. Along with the change, Daniel also quits as the president of Tmall technology company which is also one of the subsidiaries of Alibaba Group focusing on big brands. Taobao (China) Software Co., Ltd. was establ...

   CEO,ALIBABA,TAOBAO,DANIEL ZHANG     2022-04-24 07:45:48

  5 Reasons Your Javascript Stinks

Javascript gets a bad rap on the Internet, but there are few languages that are so dynamic, so widespread, and so deeply rooted in our lives as Javascript is. The low barrier of entry leads some people to call it a script kiddie language, others scoff at the concept of a dynamic language while riding their statically typed high horse. You and Javascript just got off on the wrong foot, and now you've made it angry. Here's five reasons why your Javascript code sucks.1. You're not using a namespace...

   JavaScript,Good,Habit,Prototype,OOP     2011-04-13 12:25:37