Help us understand the problem. What is going on with this article?

println is not console.log in Scala.js

More than 1 year has passed since last update.


val obj = js.Dynamic.literal(xxxx = 1)
println(obj)                        // => [object Object]  // => { xxxx: 1 }


js.Objectを出力するのにはconsole.logが適切そうだけど、case classを出力したい場合はprintlnを使うほうが便利。

case class Hoge(xxxx: Int)
val obj = Hoge(1)
println(obj)                                 // => Hoge(1)  // => Hoge(1)

case classは何らかの方法でjs側で扱えるものに変換しなけれぼconsole.logで出力することはできない。js側でObjectとしてそのまま使うことはできない。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away