当前位置:网站首页>Object creation and invocation code example
Object creation and invocation code example
2022-06-25 05:02:00 【Dai Sensen】
One . Literal creation
1. establish
The properties or methods inside take the form of key value pairs key Property name : value Property value
var obj={
name:' Zhang San ',
age:18,
sex:' male ',
sayHi:function(){
console.log(' Hello ');
}
}
2. call
console.log(obj.name);
console.log(obj['age'];
obj.sayHi();
Two .new Object
1. establish
var obj=new Object();
obj.name=' Zhang Sanfeng ';
obj.sex=' male ';
obj.age=18;
obj.sayHi=function(){
console.log(' Hello ');
}
2. call
console.log(obj.name);
console.log(obj['sex']);
obj.sayHi();
3、 ... and . Constructors
1. establish
function Star(){
this.name=name;
this.sex=sex;
this.age=age;
this.sing=function(sang){
console.log(sang);
}
}
2. call
var ldh=new Star(' Li Denghui ', 18, ' male ');
console.log(ldh.name);
console.log(ldh.sex);
ldh.sing(' Ice rain ');
var zxy=new Star(' Jacky Cheung ', 19, ' male ')
console.log(zxy['name']);
console.log(zxy['age']);
zxy.sing(' Li Xianglan ');
边栏推荐
- 本轮压力测试下,DeFi协议们表现如何?
- 为什么SQL语句命中索引比不命中索引要快?
- Filter & listener (XIV)
- Penetration test - directory traversal vulnerability
- dotnet-exec 0.4.0 released
- Student achievement management system based on SSH
- Introduction to the hardest core PWN in the whole network_ Graphic analysis
- Penetration information collection steps (simplified version)
- How PHP gets the user's City
- OLAP analysis engine kylin4.0
猜你喜欢

EL & JSTL (XIII)

What is Ethernet and how to connect the computer

电脑的dwg文件怎么打开

Student achievement management system based on SSH

以太网是什么要怎么连接电脑

Notes on non replacement elements in the line (padding, margin, and border)

多睡觉,能减肥,芝加哥大学最新研究:每天多睡1小时,等于少吃一根炸鸡腿...

绝了!自动点赞,我用 PyAutoGUI!

高效的NoSQL数据库服务Amozon DynamoDB体验分享

Difference between asemi high power FET and triode
随机推荐
Fun CMD command line~
Write shell script error summary
There is 404 in the laravel visit, except the home page is redirected; Index php
Penetration test - directory traversal vulnerability
Efficient NoSQL database service Amazon dynamodb experience sharing
How do the defi protocols perform under this round of stress test?
"Daily practice, happy water" 1108 IP address invalidation
Redis (17)
JS, BOM, DOM (VI)
buuctf web
Get to know the drawing component of flutter - custompaint
Laravel Aurora push
TeeChart Pro ActiveX 2022.1
Deeply understand the characteristics of standard flow and off standard elements
WPF uses Maui's self drawing logic
Compatible with Internet Explorer
win11蓝牙无法连接怎么办?win11蓝牙无法连接的解决方法
cannot import name ‘escape’ from ‘jinja2’【成功解决】
Virtual honeypot Honeyd installation and deployment
【FLink】access closed classloader classloader. check-leaked-classloader