I am Hack Sparrow
Captain of the Internets.

Strict Typed JavaScript

I was playing around with JavaScript's typeof operator when it occurred to me if strict typing could be implemented in JavaScript. Googled "strict data typing in javascript" and came across "JS Strict Data Types" by ajaxonomy.com. JS Strict Data Types currently implements Integer, Float, String, and Boolean strict data types.

Can't think of any reason why one would want strict typing in JavaScript, at least at this stage of JavScript engines in popular browsers, but implementing something like this is fun. Probably the inspiration behind the development was the technical challenge of the process, rather than the usefulness of the result.

How functional is the JS Strict Data Types library? As of this writing, the library seems to be concerned only about creating the data types. It is not concerned about validating the function arguments, thus making it an incomplete functional implementation of strict data typing in JavaScript.

Can you think of a way to implement strict function arguments in JavaScript? I have an idea, may be not the best, but functional it will be. It involves use of the Hungarina notation and inheritence. I will post the concept in one of my upcoming posts.

Make a Comment