Consider javascript already support for default parameters, so maybe we can use the default parameter to specify the strong type.

# 罗勇刚(Yonggang Luo) (10 years ago)

For example:

function addWithType(a = int64(0), b = int64(0)) { return a + b; }

This function is input add two int64 and return a int64

# Benjamin Gruenaum (10 years ago)

What about non-default parameters?

# Jordan Harband (10 years ago)

What if I have an "int64" function already defined? Will this skip over my int64 function? What about a = something(0) - will that call my "something" function, whereas "int64" is special and skipped over?

# Edwin Reynoso (10 years ago)

Don't you just mean:

function addWithType(a=0, b=0) {
  return int64(a) + int64(b);
}
# Emanuel Allen (10 years ago)

I like to use what the language already have so if we can denote the type by constructor:

Function foo(a=Number(64),b=String()){ return b+a; }

Sent from my iPhone

# Caitlin Potter (10 years ago)

How do you distinguish between function f(a = defaultComesFromEvaluatingSomeFunction(true)) from function f(a = StrongType(true))?

It’s ambiguous which one is meant, and that doesn’t really work.

# Gary Guo (10 years ago)

If strong type is needed, why not use TypeScript?

# 罗勇刚(Yonggang Luo) (10 years ago)

Well, native support means better performance for browsers.

2015-05-20 17:02 GMT+08:00 Gary Guo <nbdd0121 at hotmail.com>: