Airbnb Frontend Experience
[Airbnb] - [Senior Frontend Engineer] - [Tech screen]
Description Template:
Level: [G9]
Education: [BS]
Years of Experience: [8]
Questions Asked: [Event Emitter]
Part 1
const person = new Model({ name: 'Bob', age: 26 })
person.get('name') // Bob
person.get('age') // 26
person.set('age', 32)
person.get('age') // 32
Part 2
Implement has and unset
person.has('age') // true
person.unset('age')
person.has('age') // false
Part 3
Implement listener
person.on('change', function(key, oldVal, newVal) {
console.log("attribute", key, "was change from", oldVal, "to", newVal)
})
Part 4
Implement listener for any attribute
person.on('change:age', function(key, oldVal, newVal) {
console.log("attribute", key, "was change from", oldVal, "to", newVal)
})