/*
function Person(name, age){
this.name = name;
this.age = age;
}
let person = new Person('kobe', 40);
console.log(person);
*/
//定义一个人物的类
class Person{
// 类的构造方法
constructor(name, age){
this.name = name;
this.age = age;
}
// 类的一般方法
showName(){
console.log('调用父类的方法');
console.log(this.name, this.age);
}
}
let person = new Person('kobe', 40);
console.log(person);
// person.showName();
// 子类
class StarPerson extends Person{
constructor(name, age, salary){
super(name, age);
this.salary = salary;
}
// 父类的方法重写
showName(){
console.log('调用子类的方法');
console.log(this.name, this.age, this.salary);
}
}
let sp = new StarPerson('wade', 36, 152450000);
console.log(sp);
sp.showName();
let str = 'asdfohsvckxnlck';
// console.log(str.includes('t'));
// console.log(str.includes('a'));
// console.log(str.startsWith('a'));
// console.log(str.endsWith('k'));
console.log(str.repeat(5));
console.log(0b1010);//10
console.log(0o56);//46
console.log(Number.isFinite(123));//true
console.log(Number.isFinite(Infinity));//flase
console.log(Number.isNaN(NaN));//true
console.log(Number.isInteger(123));//true
console.log(Number.isInteger(123.456));//false
console.log(Number.isInteger(123.0));//true
console.log(Number.parseInt('123abc456'));//123
console.log(Number.parseInt('a123abc456'));//NaN
console.log(Math.trunc('123.123'));//123
let btns = document.getElementsByTagName('button');
Array.from(btns).forEach(function(item, index){
console.log(item);
})
let arr = Array.of(1, 4, 'abc', true);
console.log(arr);
let arr2 = [2,3,4,2,5,7,3,6,5];
let result = arr2.find(function(item, index){
return item > 4;
});
console.log(result);//5
result = arr2.findIndex(function(item, index){
return item > 4;
});
console.log(result);//4
console.log(0 == -0);//true
console.log(NaN == NaN);//false
console.log(Object.is(0, -0));//false
console.log(Object.is(NaN, NaN));//true
let obj = {};
let obj1 = {username:'iverson', age:43};
let obj2 = {sex: '男'};
Object.assign(obj, obj1, obj2);
console.log(obj);
let obj3 = {};
let obj4 = {money: 5000000};
obj3.__proto__ = obj4;
console.log(obj3);
console.log(obj3.money);
console.log(2 ** 3);//8
let arr = [1,4,5,6,'abc'];
console.log(arr.includes('a'));//false
console.log(arr.includes('abc'));//true
console.log(arr.includes(4));//true
'use strict'
require('./check-versions')()
process.env.NODE_ENV='production'
constora=require('ora')
constrm=require('rimraf')
constpath=require('path')
constchalk=require('chalk')
constwebpack=require('webpack')
constconfig=require('../config')
constwebpackConfig=require('./webpack.prod.conf')
constspinner=ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot,config.build.assetsSubDirectory),err=>{
if(err)throwerr
webpack(webpackConfig, (err,stats)=>{
spinner.stop()
if(err)throwerr
process.stdout.write(stats.toString({
colors:true,
modules:false,
children:false,//If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks:false,
chunkModules:false
})+'\n\n')
if(stats.hasErrors()) {
console.log(chalk.red('Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan('Build complete.\n'))
console.log(chalk.yellow(
'Tip: built files are meant to be served over an HTTP server.\n'+
'Opening index.html over file:// won\'t work.\n'
))
})
})
'use strict'
constchalk=require('chalk')
constsemver=require('semver')
constpackageConfig=require('../package.json')
constshell=require('shelljs')
functionexec(cmd) {
returnrequire('child_process').execSync(cmd).toString().trim()
}
constversionRequirements=[
{
name:'node',
currentVersion:semver.clean(process.version),
versionRequirement:packageConfig.engines.node
}
]
if(shell.which('npm')) {
versionRequirements.push({
name:'npm',
currentVersion:exec('npm --version'),
versionRequirement:packageConfig.engines.npm
})
}
module.exports=function() {
constwarnings=[]
for(leti=0; i constmod=versionRequirements[i] if(!semver.satisfies(mod.currentVersion,mod.versionRequirement)) { warnings.push(mod.name+':'+ chalk.red(mod.currentVersion)+'should be'+ chalk.green(mod.versionRequirement) ) } } if(warnings.length) { console.log('') console.log(chalk.yellow('To use this template, you must update following to modules:')) console.log() for(leti=0; i constwarning=warnings[i] console.log(''+warning) } console.log() process.exit(1) } }