To add private variable to this Javascript literal object

时间:2022-09-23 10:18:54

You can use number as function/variable name, the numberic name can't be accessed from parent scope, but can be accessed by 'this' in private scope.

var o=
{
attr1:'value of attr1',
1:'private attr ,the index is 1',
301:function(){
console.log('private function , name is 2');
},
fun1:function(){
console.log(this[1]);
this[301].call(this);
}
}; o.fun1();

To add private variable to this Javascript literal object的更多相关文章

  1. Private Variable

    Any variable defined inside a function is considered private since it is inaccessable outside that f ...

  2. unity c# script error CS0664: Literal of type double cannot be implicitly converted to type `float'. Add suffix `f' to create a literal of this type

    例如在unity c# script中定义 private float x=0.0; 则会报 error CS0664: Literal of type double cannot be implic ...

  3. python之private variable

    [python之private variable] Since there is a valid use-case for class-private members (namely to avoid ...

  4. Python私有变量(Private Variable)

    Variables can be private which can be useful on many occasions. A private variable can only be chang ...

  5. Private Variable and Private Method - Python 私有变量 和 私有方法

    Private Variable and Private Method Python 不象 Java 那样, 通过 private 关键字创建私有属性, python 通过更简洁的实现了'私有属性', ...

  6. JavaScript中Object的总结

    基于原型继承,动态对象扩展,闭包,JavaScript已经成为当今世界上最灵活和富有表现力的编程语言之一. 这里有一个很重要的概念需要特别指出:在JavaScript中,包括所有的函数,数组,键值对和 ...

  7. JavaScript中Object.prototype.toString方法的原理

    在JavaScript中,想要判断某个对象值属于哪种内置类型,最靠谱的做法就是通过Object.prototype.toString方法. ? 1 2 var arr = []; console.lo ...

  8. 从头开始学JavaScript (十一)——Object类型

    原文:从头开始学JavaScript (十一)--Object类型 一.object类型 一个object就是一系列属性的集合,一个属性包含一个名字(属性名)和一个值(属性值). object对于在应 ...

  9. JavaScript之Object拆解

    转载烦请注明原文链接: https://github.com/Xing-Chuan/blog/blob/master/JavaScript/JavaScript%E4%B9%8BObject%E6%8 ...

随机推荐

  1. Greedy:The Water Bowls(POJ 3185)

    水池 题目大意:给定一个20的数组,全都是0和1,可以翻一个数改变成另一个数(0或者1),但是其左右两边的数都会跟着变为原来的相反数,问你怎么用最小的操作数使全部数变成0 这一题的:满足 1:翻转次序 ...

  2. Mozilla Firefox 24.0 Beta 5 发布

    Mozilla今天将Firefox 24.0 Beta 5版本放到了FTP的release目录,新版开始全面支持OS X 10.7全新的滚动条样式,禁止网站插件运行的功能出现在任务栏左侧,调整了界面U ...

  3. [转]C程序内存区域分配(5个段作用)

    [转]C程序内存区域分配(5个段作用) 2012-08-10 14:45:32|  分类: C++基础|字号 订阅     参考:http://www.360doc.com/content/11/03 ...

  4. arm 基本

    ARMr0-r4 传递参数与返回值r7 帧指针 指向母函数被调用子函数在栈看中的交界栈帧指针(Frame Pointer).指向前一个保存的栈帧(stack frame)和链接寄存器(link reg ...

  5. [补档]happiness

    happiness 题目 传送门:http://cogs.pro/cogs/problem/problem.php?pid=1873 高一一班的座位表是个n×m的矩阵,经过一个学期的相处,每个同学和前 ...

  6. HTML5 — Wed SQL 本地数据库示例

    1 <!DOCTYPE html>2 <html lang="en">3 <head>4 <meta charset="UTF- ...

  7. php 慢配置文件

    [root@localhost etc]# cat php-fpm.conf[global]pid = /usr/local/php/var/run/php-fpm.piderror_log = /u ...

  8. LeetCode111&period;二叉树的最小深度

    给定一个二叉树,找出其最小深度. 最小深度是从根节点到最近叶子节点的最短路径上的节点数量. 说明: 叶子节点是指没有子节点的节点. 示例: 给定二叉树 [3,9,20,null,null,15,7], ...

  9. OpenStack的基本概念与架构图

    https://blog.csdn.net/zjluobing/article/details/51489325 OpenStack项目是一个开源的云计算平台,旨在实现很简单,大规模可伸缩,功能丰富. ...

  10. TXT文件用法大全【荐】--------按键精灵

    来源:全文链接 (3)读取TXT文件指定某一行的第?到第?个字 UserVar t=2 "读出txt第几行文本" UserVar i=5 "从第几个字开始读取" ...