开发者

What (kind of) project could I create to learn JavaScript?

开发者 https://www.devze.com 2022-12-25 09:57 出处:网络
I started learning JavaScript a while ago. It\'s a fairly easy programming language considering that I learned Java in university, that I know php pretty well and that I already played around with pyt

I started learning JavaScript a while ago. It's a fairly easy programming language considering that I learned Java in university, that I know php pretty well and that I already played around with python and ruby. The problem is that to properly learn a programming language I usually create a project. In javascript, I just don't know what kind of project I could create - that is, a project that is not web-based or related to the web br开发者_C百科owser. Can I create javascript shell scripts? Where is javascript commonly used beside the web browsers?

So, can someone actually give me some ideas please?


Can I create javascript shell scripts?

You bet!

  • On Windows, you can do this by using cscript.exe (you can even set up a file extension -- I use jx -- that automatically runs when you just double-click the filename or use it as a command in a shell: Just associate that file extension with the command "c:\WINDOWS\system32\cscript.exe" /e:JavaScript /nologo "%1" %*). This is (and I've measured carefully) about 80 milion times better than fighting with Windows' batch language. About. (And if you don't want to use JScript — Microsoft's variant of JavaScript — you even have options, see below.)
  • On *nix, a shell script can be set to run in any installed interpreter (that's what the #!... line at the top is telling the command interpreter). I expect you'll find a few if you search around.
  • On the Mac, you probably have JavaScriptCore installed in /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc
  • And on all of the above, if you like, you can install Rhino and Java and get platform independence and access to a huge range of library functionality. Rhino has a built-in shell, or you can tell it to execute a specific JavaScript file. It interoperates with Java, so if you do this, you have easy access to all essentially of the functionality available to Java.

Where is javascript commonly used beside the web browsers?

I use it for shell scripting on Windows. I also use it as a server-side language, for instance in the server-side part of a web application. It's also used in other environments where a lightweight, powerful scripting language is useful, such as in the MongoDB shell environment (you can use it to query MongoDB data) and stored procedures.

All of that said, writing a browser-based project is a rich, interactive way to learn the language.


windows Sidebar Gadgets, Apple's Widgets, and Google Desktop Gadgets are all created using HTML/ JS/ CSS.

I learnt Javascript by creating a few small Windows Sidebar Gadgets.

Getting Started

Sidebar Reference


You could use javascript to make HTA (HTML Applications) that can be run outside of the the web browser sandbox.
MSDN intro to HTA Applications
Javascript Tutorial on HTML Applications


You could write a non-blocking TCP server. Node.js supports that.


Common uses of javascript outside of browsers are WSH scripts and HTA applications on Windows and Dashboard widgets on Mac.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号