![]() This takes the base for the conversion as an optional second argument, which you should always provide: > parseInt("123") You can convert a string in to a number using the built-in parseInt() function. There's also a built in object that I forgot to mention earlier called Math to handle more advanced mathematical functions and constants: Math.sin(3.5) The standard numeric operators are supported, including addition, subtraction, modulus (or remainder) arithmetic and so forth. There's no such thing as an integer in JavaScript, so you have to be a little careful with your arithmetic if you're used to maths in C or Java. Numbers in JavaScript are "double-precision 64-bit format IEEE 754 values", according to the spec. Things are a lot easier if we stick with the first diagram though. So the type diagram looks more like this:Īnd there are some built in Error types as well. And to be technically accurate, functions are just a special type of object. And Dates and Regular Expressions, which are objects that you get for free. And Arrays, which are a special kind of objects. oh, and Undefined and Null, which are slightly odd. JavaScript programs manipulate values, and those values all belong to a type. Let's start off by looking at the building block of any language: the types. To add some variety, I'll be demonstrating some alternative JavaScript hosts later in the tutorial. The most common host environment is the browser, but JavaScript interpreters can also be found in Adobe Acrobat, Photoshop, Yahoo!'s Widget engine and more. It is designed to run as a scripting language in a host environment, and it is up to the host environment to provide mechanisms for communicating with the outside world. Unlike most programming languages, the JavaScript language has no concept of input or output. For familiarity, I will stick with the term JavaScript throughout. ![]() I'm going to focus almost exclusively on the edition 3 dialect. This stability is great news for developers as it's given the various implementations plenty of time to catch up. ![]() The standard received a significant update as Ecmascript edition 3 in 1999, and has stayed pretty much stable ever since - although edition 4 is currently in the works. Netscape submitted the language to Ecma International, a European standards organisation, which resulted in the first edition of the Ecmascript standard in 1997. Microsoft released a mostly-compatible version of the language called JScript with IE 3 several months later. This has been a source of confusion ever since. It's was originally going to be called LiveScript, but was renamed in an ill-fated marketing decision to capitalise on the popularity of Sun Microsystem's Java language - despite the two having very little in common. ![]() JavaScript was created in 1995 by Brendan Eich, an engineer at Netscape, and first released with Netscape 2 early in 1996. It's useful to start with an idea of the language's history. The last year has seen the launch of a number of high profile JavaScript applications, showing that deeper knowledge of this technology is an important skill for any web developer. While often derided as a toy, beneath its deceptive simplicity lie some powerful language features. Why a re-introduction? Because JavaScript has a reasonable claim to being the world's most misunderstood programming language. My name's Simon Willison, and the title of this session is "A re-introduction to JavaScript". Notes made in preparation for a three hour tutorial at ETech in San Diego, March 6th 2006 Introduction # 17:38:34 A (Re)-Introduction to JavaScript ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |