例1:

var a={};  alert(a); //[object Object];

例2:

var a={

  toString:function(){

    return 1;

  }  

}

alert(a);  // 1

a+1;      //2

例3:

var a={toString:function(){return 1;},valueOf:function(){reuturn 2};}

alert(a); // 1

a+1;     // 3

---------------------------------------------------------------------------------------------------------------------------------------------------

+操作会如下步骤:

  1. Let lref be the result of evaluating AdditiveExpression.

  2. Let lval be GetValue(lref).

  3. Let rref be the result of evaluating MultiplicativeExpression.

  4. Let rval be GetValue(rref).

  5. Let lprim be ToPrimitive(lval).

  6. Let rprim be ToPrimitive(rval).

  7. If Type(lprim) is String or Type(rprim) is String, then

    1. Return the String that is the result of concatenating ToString(lprim) followed by ToString(rprim)

  8. Return the result of applying the addition operation to ToNumber(lprim) andToNumber(rprim). See the Note below 11.6.3.

+ specification: http://es5.github.io/index.html#x11.6.1

object to primitive in javascript的更多相关文章

  1. javascript中function和object的区别,以及javascript如何实现面向对象的编程思想.

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  2. ExtJS学习-----------Ext.Object,ExtJS对javascript中的Object的扩展

    关于ExtJS对javascript中的Object的扩展.能够參考其帮助文档,文档下载地址:http://download.csdn.net/detail/z1137730824/7748893 以 ...

  3. bootstrap导航条报错 Uncaught TypeError: Cannot convert object to primitive value

    原文: https://feiffy.cc/uncaught-typeerror-cannot-convert-object-to-primitive-value 最近发现我的博客页面移动端上下拉菜单 ...

  4. Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.

    代码如下: var query = from s in db.LoginUserServices join ss in db.Services on s.ServiceType equals ss.C ...

  5. JavaScript对象 Object类型基础

    前言 JavaScript 对象是整个语言学习的一个难点.本文主要带大家入门学习Object知识 对象定义 javascript的基本数据类型包括undefined.null.boolean.stri ...

  6. 【JavaScript】Object.prototype.toString.call()进行类型判断

    权声明:本文为博主原创文章,未经博主允许不得转载. op = Object.prototype, ostring = op.toString, ... function isFunction(it)  ...

  7. JavaScript: Constructor and Object Oriented Programming

    Constructor :  Grammar: object.constructor Example: Javascript code: 1 function obj1() { this.number ...

  8. JavaScript学习总结(十一)——Object类详解

    一.Object类介绍 Object类是所有JavaScript类的基类(父类),提供了一种创建自定义对象的简单方式,不再需要程序员定义构造函数. 二.Object类主要属性 1.constructo ...

  9. Javascript Object常用方法总结

    Object.keys方法 Object.keys方法是JavaScript中用于遍历对象属性的一个方法 .它传入的参数是一个对象,返回的是一个数组,数组中包含的是该对象所有的属性名. 如: var ...

随机推荐

  1. Ionic之顺带APP

    1:Ionic简介 官方:我们设计ionic来帮助 web 开发人员能够像开发网站一样开发出强大的移动APP应用. ionic是一个html5开发APP的框架,在开发运行效率可以说是最好的H5框架,把 ...

  2. java模拟有验证码的Http登陆

    所需资源下载链接(资源免费,重在分享) Tesseract:http://download.csdn.net/detail/chenyangqi/9190667 jai_imageio-1.1-alp ...

  3. Part 1 What is SSMS?

    note that,SSMS is a client tool and not the server by itself,it is a developer machines connects to ...

  4. CSS之页面添加标签

    就是因为昨天弄这个“神奇的小标签”差点把自己的园子给废了(情节真的有这么严重),说多了都是泪啊~~(┳_┳).本来是想在页首添加这个“神奇的小标签”的,不知是插件有BUG还是代码错误当场就导致不能编辑 ...

  5. C#中的 具名参数 和 可选参数

    具名参数 和 可选参数 是 C# framework 4.0 出来的新特性. 一. 常规方法定义及调用 public void Demo1(string x, int y) { //do someth ...

  6. in/exists not in/not exists null

    in/not in exists/not exists null的理解 两个测试表 create table tmp01 as with tmp as ( select '1' as id from ...

  7. VxWorks 6.9 内核编程指导之读书笔记 -- 多任务

    概述 VxWork系统任务 任务调度 任务创建和管理 任务的错误状态 任务异常处理 共享代码和重入 概述 现代实时操作系统是基于多任务和任务间通信的概念的.多任务环境运行一个实时进程RTP可以被作为一 ...

  8. 勿在浮沙筑高台-- 关于IT技术学习的一点反思

    常常看到前辈们大牛们感慨, 感慨我们这一代人生活在最好的时代, 拥有海量的学习资源以及指数增长的新技术与新知识. 的确, 如果你是这个时代的大学生,或是初出茅庐的程序员, 你会发现有太多太多的选择,  ...

  9. 济南学习 Day 4 T2 am

    LYK 与实验室(lab)Time Limit:5000ms Memory Limit:64MB题目描述LYK 在一幢大楼里,这幢大楼共有 n 层,LYK 初始时在第 a 层上.这幢大楼有一个秘密实验 ...

  10. IOS引导页拨动4张图片最后一张停三秒进入主页,页面推送

    // //  ViewController.m // // //  Created by 张艳锋 on 15/8/26. //  Copyright (c) 2015年 张艳锋. All rights ...