Студопедия

КАТЕГОРИИ:


Архитектура-(3434)Астрономия-(809)Биология-(7483)Биотехнологии-(1457)Военное дело-(14632)Высокие технологии-(1363)География-(913)Геология-(1438)Государство-(451)Демография-(1065)Дом-(47672)Журналистика и СМИ-(912)Изобретательство-(14524)Иностранные языки-(4268)Информатика-(17799)Искусство-(1338)История-(13644)Компьютеры-(11121)Косметика-(55)Кулинария-(373)Культура-(8427)Лингвистика-(374)Литература-(1642)Маркетинг-(23702)Математика-(16968)Машиностроение-(1700)Медицина-(12668)Менеджмент-(24684)Механика-(15423)Науковедение-(506)Образование-(11852)Охрана труда-(3308)Педагогика-(5571)Полиграфия-(1312)Политика-(7869)Право-(5454)Приборостроение-(1369)Программирование-(2801)Производство-(97182)Промышленность-(8706)Психология-(18388)Религия-(3217)Связь-(10668)Сельское хозяйство-(299)Социология-(6455)Спорт-(42831)Строительство-(4793)Торговля-(5050)Транспорт-(2929)Туризм-(1568)Физика-(3942)Философия-(17015)Финансы-(26596)Химия-(22929)Экология-(12095)Экономика-(9961)Электроника-(8441)Электротехника-(4623)Энергетика-(12629)Юриспруденция-(1492)Ядерная техника-(1748)

Methods




Клиентские сценарии. Язык JavaScript. Объекты Function, Object, Number

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Functions

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number

Каждая функция в JavaScript это фактически объект Function.

new Function ([ arg1 [, arg2 [,... argN ]],] functionBody)

In JavaScript, functions are first-class objects, i.e. they are objects and can be manipulated and passed around like just like any other object.

var multiply = new Function("x", "y", "return x * y");var theAnswer = multiply(7, 6); function myFunc(theObject) { theObject.brand = "Toyota"; } var mycar = {brand: "Honda", model: "Accord", year: 1998}; alert(mycar.brand); // shows 'Honda' myFunc(mycar); // pass object mycar to the function alert(mycar.brand); // shows 'Toyota' as the brand property of // mycar was changed by the function)

 

new Object([ value ])

The Object constructor creates an object wrapper for the given value. If the value is null or undefined, it will create and return an empty object, otherwise, it will return an object of type that corresponds to the given value.

o = new Object(true); // equivalent to o = new Boolean(true);o = new Object(Boolean()); // equivalent to o = new Boolean(false);

constructor property:

o = new Object // or o = {} in JavaScript 1.2o.constructor == Object

All objects in JavaScript are descended from Object; all objects inherit methods and properties from Object.prototype, although they may be overridden. For example, other constructors' prototypes override the constructor property and provide their own toString methods. Changes to the Object prototype object are propagated to all objects unless the properties and methods subject to those changes are overridden further along the prototype chain.

 

new Number(value)

The primary uses for the Number object are:

If the argument cannot be converted into a number, it returns NaN.

In a non-constructor context (i.e., without the new operator), Number can be used to perform a type conversion.

biggestNum = Number.MAX_VALUE;smallestNum = Number.MIN_VALUE;infiniteNum = Number.POSITIVE_INFINITY;negInfiniteNum = Number.NEGATIVE_INFINITY;notANum = Number.NaN;

toExponential — Returns a string representing the number in exponential notation.

toFixed — Returns a string representing the number in fixed-point notation.

toLocaleString — Returns a human readable string representing the number using the locale of the environment. Overrides the Object.prototype.toLocaleString method.

toPrecision — Returns a string representing the number to a specified precision in fixed-point or exponential notation.

toString — Returns a string representing the specified object. Overrides the Object.prototype.toString method.

valueOf — Returns the primitive value of the specified object. Overrides the Object.prototype.valueOf method.

var d = new Date("December 17, 1995 03:24:00");print(Number(d));

 





Поделиться с друзьями:


Дата добавления: 2015-01-03; Просмотров: 405; Нарушение авторских прав?; Мы поможем в написании вашей работы!


Нам важно ваше мнение! Был ли полезен опубликованный материал? Да | Нет



studopedia.su - Студопедия (2013 - 2024) год. Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав! Последнее добавление




Генерация страницы за: 0.012 сек.