Home » Odeon Blogs » Michelle Chan »

Javascript in Shell

Javascript in Shell

I used to test out Javascript in browsers' console. But I just found a way to run it in my Terminal.


No installation! There is JavascriptCore in Mac OS X called jsc, which is in /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc. 

So I created a soft link to /bin :

  1. ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /bin/jsc

Let's test JSC in your terminal,

  1. $ jsc
  2. > "hello world"
  3. hello world
  4. > [] + {}
  5. [object Object]
  6. > {} + []
  7. 0
  8. > Array(16).join("haha" - 1)
  9. NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
  10. >

Enjoy... 


Categories: Javascript OS X


Tagged as: Javascript Terminal

Discussion

  1. the example works for my ibook and my ubuntu! thank you for sharing!




Leave a Comment :

(required)


(required)




(required)




(required)






Leave a Comment


Page generated in: 0.15s