1
0

More than 5 years have passed since last update.

【CoffeeScript】findの小さなサンプルメモ

Last updated at Posted at 2018-05-30

メモ

まず、JavaScriptの基本

Array.prototype.find() - JavaScript | MDN https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/find

サンプル

[1,2,3]のうち、1より大きい値の最初のものを出力

test.coffee
arr = [1,2,3]
console.log arr.find (element) ->
          element > 1
実行結果
% coffee array-test.coffee
2

JavaScriptの変換されたやつ↓

test.js
  console.log(arr.find(function(element) {
    return element > 1;
  }));
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0