如何面试一个前端开发者?
function spacify(str) {
return str.split('').join(' ')
}
console.log(spacify('hello world'))
String.prototype.spacify = function() {
return this.split('').join(' ')
}
console.log('hello world'.spacify())
function log() {
var args = Array.prototype.slice.call(arguments)
args.unshift('(app)')
console.log.apply(console, args)
}
log('hello', 'world')
var User = {
count: 1,
getCount: function(x, y) {
console.log(x, y)
return this.count
}
}
Function.prototype.bind = Function.prototype.bind || function(context) {
var self = this
return function() {
return self.apply(context, arguments)
}
}
console.log(User.getCount.bind(User)(1, 2))