loading...
Cover image for JavaScriptの使い方

JavaScriptの使い方

ryunishimura profile image Ryu Nishimura Updated on ・1 min read

更新していくよ

References

JavaScript reference

JavaScript and HTML DOM Reference

Hacks and Tips

  • Object with forEach
let characters = [{ name: 'bulma' }, { name: 'goku' }]
Object.keys(characters).forEach(key => {
  console.log(characters[key];)
})
Enter fullscreen mode Exit fullscreen mode
  • Judgment from Array(Object)(Presence of specific value)
let characters = [{ name: 'bulma' }, { name: 'goku' }]
funtion() {
  return characters.some(c => {
    if(c.name === 'goku') {
      return true;
    }
  })
}
Enter fullscreen mode Exit fullscreen mode
  • Find index in Array

Array.prototype.findIndex()

let characters = [{ name: 'bulma' }, { name: 'goku' }]
let target = characters.findIndex(c => name === 'bulma')
Enter fullscreen mode Exit fullscreen mode
  • Find in Array

Array.prototype.find()

let characters = [{ name: 'bulma' }, { name: 'goku' }]
let target = characters.find(c => name === 'bulma')
// => { name: 'bulma' }
Enter fullscreen mode Exit fullscreen mode
  • includes

Array.prototype.includes()

  • keyの存在確認
"lang" in user
this.$set(this.testObject, 'value', 'test2-Value')
Enter fullscreen mode Exit fullscreen mode
  • array.mapは配列の長さは変わらない。再構築する。
  • array.fliterは配列の条件によって配列を再構築する。

Posted on by:

ryunishimura profile

Ryu Nishimura

@ryunishimura

Favorites❤️ JAMStack/Serverless/Nuxt.js/Contentful

Discussion

pic
Editor guide