Giter Club home page Giter Club logo

Comments (15)

azu avatar azu commented on August 19, 2024

特に四則演算を説明するには、暗黙的な型変換と明示的な型変換について事前に知っていないと難しそう。 #53
逆に暗黙的な型変換をしてはいけない理由をちゃんと出す必要がある。

一つ具体的でES2015ではまる可能性が高いものとして、 Symbol() + "文字列"がある。

Symbol() + "文字列";

はエラーで

String(Symbol()) +"文字列"

ならOKであるというのは、暗黙的な型変換に頼っては行けない理由の一つ。

from js-primer.

azu avatar azu commented on August 19, 2024

話の大きな流れとしては、
演算子の紹介 -> 異なる型を演算したらどうなる? -> #53 型変換の仕方
となるはず

演算子 -> 暗黙の型変換 -> 明示的な型変換

from js-primer.

azu avatar azu commented on August 19, 2024
Operator Description Example
+ 足し算 1+1 === 2
- 引き算 1-1 === 0
* 掛け算 2*8===16
/ 割り算 8/2===4
** べき乗 2**3===8

やたら大量にでてくるのでグループ毎に簡易なまとめをもうけるのが良さそうな気がする

from js-primer.

azu avatar azu commented on August 19, 2024

** で∞とNaNになるパターン一覧
http://www.ecma-international.org/ecma-262/7.0/#sec-applying-the-exp-operator

基本的に IEEE 754 なので、IEEE 754に簡単に触れるのがいい気がするけど、
IEEE 754についての細かい仕組みは理解しなくてもプログラミングできる気はするな。
一定の上限とかがあるみたいなことがわかっていれば

from js-primer.

azu avatar azu commented on August 19, 2024

分類はこれでやるのが良さそう。

12 ECMAScript Language: Expressions

12.1 Identifiers
12.2 Primary Expression
12.3 Left-Hand-Side Expressions
12.4 Update Expressions
12.5 Unary Operators
12.6 Exponentiation Operator
12.7 Multiplicative Operators
12.8 Additive Operators
12.9 Bitwise Shift Operators
12.10 Relational Operators
12.11 Equality Operators
12.12 Binary Bitwise Operators
12.13 Binary Logical Operators
12.14 Conditional Operator ( ? : )
12.15 Assignment Operators
12.16 Comma Operator ( , )

#32 (comment) へ加えた

from js-primer.

azu avatar azu commented on August 19, 2024

これは紙面的な作りと、ウェブ向けの作りがあったほうがよいなと思った。
例えば、実行環境があるウェブ向けなら、そのばで実行できることを前提とした作りの方が理解がし易い。
演算子ってアルゴリズム的に理解するものでもないはずなので、ひたすら実例で理解した方がいい。

from js-primer.

azu avatar azu commented on August 19, 2024

等価性の比較とその使いどころ - JavaScript | MDN

Object.is=== の違いについて分かりやすい。
Object.is って変化したって事を知りたい時に(shallowEqual)で使ってるぐらいな印象。
他のケースで Object.is って何に使うんだろ? TypedArrayとかそっちなのかなー

from js-primer.

azu avatar azu commented on August 19, 2024

見間違いやすい演算子の例が欲しいな。
グループ演算子を使って明示という感じの

from js-primer.

azu avatar azu commented on August 19, 2024

Effective JavaScriptの第1章が浮動小数点数とかNaNの話なので参考になりそう

from js-primer.

azu avatar azu commented on August 19, 2024

JavaScript - なぜ右辺を評価しないことが遅延なのか(41847)|teratail
&&について

from js-primer.

azu avatar azu commented on August 19, 2024

条件演算子と短絡評価についてはからめて話をしたい気がする。

const と 条件演算子 と 短絡評価。
なので関数の引数の処理をやってみるのがいいのかな。
ある具体的な形の関数にしたいなー

長期的には、この部分がデフォルト引数とかに繋がる気がする

from js-primer.

azu avatar azu commented on August 19, 2024

特殊な単項演算子についてはここで説明するのはやめました。
ここでは検索が難しい記号の演算子をまとめるという目標にしています。
なので、すべての演算子をまとめるのが目的ではないのでやめます。

以下は草案の文章


単項演算子(特殊)

delete演算子

オブジェクトのプロパティ または 配列の指定した添字を削除する。

var obj = { key: "value" };
delete obj.key;
console.log(obj.key); // => undefined
var array = [5, 10];
delete array[0];
console.log(array[0]); // => undefined
console.log(array[1]); // => 10

変数を削除する演算子ではない。

var foo = "val";
delete foo; // => Error

typeof演算子

説明済み。プリミティブとオブジェクトの判定について。

typeof "value"; // => "string"
typeof 42; // => "number"

void演算子

undefinedを返す特性を利用した圧縮やブックマークレットの仕組みに使われている。

void 0;// => undefined

関係演算子

in演算子

for...in文と同じ。

var object = { "key": "value" };
"key" in object; // => true
Reflect.has(object, "key"); // => true
object.hasOwnProperty("key"); // => true

from js-primer.

azu avatar azu commented on August 19, 2024

https://asciidwango.github.io/js-primer/basic/operator/ landed.
全体的に細かすぎるのでどうにかできたらどうにかしたい感じではある。

一つの節に演算子をまとめるの目的

ひとまず目的は達成したので閉じます。

from js-primer.

azu avatar azu commented on August 19, 2024

+= とかのについて書いてない

from js-primer.

azu avatar azu commented on August 19, 2024

Operatorが長すぎる問題
比較演算子だけを取り出すという手法がありそう。
プリミティブとオブジェクト #145 の問題で、基本型と参照型の違いの話として"比較"がでてくるので、
これだけを先に取り出してしまうのはありそう。

from js-primer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.