Brenden Eich born 1961 Pittsburgh, Pennsylvania.
November 1996, this is the true inception of ECMAScript. Netscape submitted the language to ECMA (European Computer Manufacturers Association) and in the June of 1997 ECMA-262, the official designation for the ECMAScript standard was published.
1.0 – March 1996, Netscape Navigator and Internet Explorer 3 exclusively
1.1 – August 1996. Netscape Navigator
1.3 – October 1998, the first browser implementations of ECMA-262, Netscape Navigator, Internet Explorer 4.0 and Opera 5.
1.4 – Netscape Server and Opera 6
1.5 – November 2000, ECMA-262 or ECMAScript 3 was now implemented in all of today’s browsers. This was also the final year for Netscape Navigator and the first year for Mozilla and Google Chrome.
1.6 – November 2005, unofficially known as E4x it was only implemented in Mozilla browsers. Array and string generics added.
1.7 – October 2006, only implemented in Mozilla and Google Chrome
1.8 – June 2008, only implemented in Mozilla and Opera, expression closures added
1.8.1 – Mozilla only, native JSON support added
1.8.2 – June 22, 2009. Only implemented in Mozilla.
This is where things got shook up. For years’ browser developers fought over this language and its implementation, with any disparities appearing across browsers. The community fought this out, and development and adoption of the language stuttered.
We won’t see this in SharePoint until the version after SharePoint 2016, but we can start to use the features and way of programming now. With this in mind, I will be future proofing your mind set, looking forwards to ECMAScript 7 and beyond.
We have full stack development, meaning that we can program and compile down to machine code if we have the need. This allows for new types of development practices, allowing smaller teams without the need for a diversity of skills to flourish alongside other larger teams.
Today this leaves us with a robust language which we have a vast understanding and years of experience in development.
We use traditional development practices and solid Computer Science to develop asynchronous powerful applications, that give the best possible experience an end user could want for.
So where do we go from here? We are in the middle of ECMAScript 5 and 6, it can be a hard place to be, between two standards. As we do in other programming language, we can use shims to ensure support is available. While our core libraries use the latest of development practices and syntactic sugar.
If you aren’t familiar with these concepts, they will be looked at in depth late on in the book.
While this is true to an extent in the definition as provided by Wikipedia. It is also wrong. Whether a language is interpreted or not depends on the implementation. Implementation has nothing to do with the specification. A language decides if it is to be interpreted or compiled. ECMA-262 states an environment, not that it is an interpreted language, and feel this is an important fact to have a handle on.
The general advice is, if it seems confusing and pointless then you need to stay away from it. I say no learn what is going on, so that you have the tools to hand when you need them.
A Abstract Data Type isn’t an Abstract Class, or Abstraction. It’s an object that is defined by behavior, where as in C# we use Data Structures which are an implementation of multiple Abstract Data Types to create a structure. In C# each Abstract Data Type is wrapped by a class to give it structure, it defined how it is to be compared, how it is built, what are it’s limits.
- a double-precision 64-bit binary format IEEE 754 value. What is that exactly though? The Number type is a primitive with an Object implementation (See Boolean above). It means that it is a precise but not perfect representation of a fractional number. Indeed in this standard 0.1 + 0.2 = 0.3000000000000000444089209850062616169452667236328125. This is because a number in this format is in Scientific Notation (10 = 1 x 101). We have 11 bits for the exponent (The front bit) and 52 for the significand (The bit in the superscript after the number). This means that we aren’t very precise with this. In C# we tend to use Decimal numbers instead of Floating point numbers although both are available. The reality is Floats are no good for thing’s like finance or anything exact. Decimals are much better (Still not perfect, as they would be Fixed Point numbers, as in Fixed Point Arithmetic) and technically since a Decimal does store the Point inside it’s encoding, it is still a Float, but more suited to financial data as they are decimal accurate. This whole topic will get it’s own blog post in the future.
- 16bit UTF-16 string of characters that are stored with their length separate. In C-Like languages you normally have a null terminated string.
- A new type added to ES6 is the Symbol. In order to add unique properties and behavior we got the Symbol. A symbol is used a unique identifier and on creation is given a String description. These can be used to create new non iterateable properties on objects, or unique types for constants.
Initialisation & Prototypes
While the implementation is very close to inheritance as we don’t physically copy over the base properties, we make references to them, we aren’t building a class which describes the object first. We build an object, we add to it, we inherit from it and alter the inherited object to create a new object.
Scope & Closures
In C# it appears we can create delegated methods inside of other methods. However this isn’t truly the case, a delegated method is a separate method in C# that is just written inside of the method you are working in. You only have access to the values that are passed into the scope,
A Closure however has access to anything it is in scope of. It’s parent’s variables are accessible, and when used with current state in mind this can be a very powerful concept.
Closures allow us to create well nested Methods, that control privacy, and create Objects in a monadic fashion.
What is a Monad though? A monad is what it is to define a set of operations to create a chain of functionality. It is called a “Programmable Semi-Colon” by some, it is in essence the linkage between functions.
We have moved on from manual Monad programming mostly, now we use Promises to achieve this behavior to get a Workflow style of programming.
We have the ability to iterate over objects and data sets, using one of many methods implemented. Due to the vastness of difference in each iteration method this will be a separate blog post on it’s own.
This is two fold, first you don’t want your users seeing errors, or causing their entire SharePoint page to stop working. Further to this though most exploits use exceptions in code to perform some form of bypass. Preventing your code from throwing errors is one of the first lines of defense against this.
Even if you build in all appropriate checks, use error handling, and use logging to trace these errors back to the source so that you can manage the defects.
Write code comments. Explain the intent of a method, it’s input and output. Explain any complex code that you haven’t been able to refactor. Do this and your supportability and maintainability costs of your code reduces dramatically. Some companies look at Code Comment Density to check this as a metric, for me as long as you cover these three things in your code, no matter what language you write you will have done your job.
- Output and intent
- Complex code
Most modern frameworks will do the DOM Handling for you, however knowing what you are doing, allows you to optimise even very well optimised Frameworks such as Angular even more.
More on Standards
If you want to five into the standard straight away then I recommend looking at the next version draft, and the current version. The next standard draft can be found here ECMAScript® 2019 Draught and for the published edition you can find it here ECMAScript® 2015 Language Specification