小编bas*_*rat的帖子

ES6 Map如何工作

根据我对文档的理解(这里这里),需要引用内存地址才能工作:

const foo = {};
const map = new Map();
map.set(foo,'123');  // Can only be done if memory address of `foo` is known. Any other shimming would require stringification of foo
Run Code Online (Sandbox Code Playgroud)

这是因为JavaScript对象{}键只能是字符串(至少在ES5中).

但是我看到Map垫片可用:https://github.com/zloirock/core-js#map.我尝试阅读源代码,但它过于整齐抽象(内部使用强大的集合,然后再导入10个文件)

请回答以下任何一项

  • 是否有一个简单的技巧,甚至可以真正完成(没有字符串化)?
  • 也许它会变异foo以在其上存储一些字符串然后将其用作关键字?
  • 还有别的,也许我正在阅读文档错误?

javascript typescript ecmascript-6

14
推荐指数
2
解决办法
1583
查看次数

11
推荐指数
1
解决办法
2268
查看次数

实现索引接口

我如何实现可索引的接口:

interface fooInterface{
    // indexable
    [index:string]:number;
    [index:number]:number;          
}


class Foo implements fooInterface{
    // What goes here? 
}
Run Code Online (Sandbox Code Playgroud)

typescript

11
推荐指数
1
解决办法
5277
查看次数

告诉RequireJS不要缩小文件

我怎样才能使用grunt-contrib-requirejs配置或甚至r.js配置来不缩小特定文件.

我可以通过选项禁用所有文件的缩小optimize: 'none'.但我不知道如何为单个文件禁用它.

  options: {                                        
      // Do not minify these files: 
      // 'jquery'
      optimize: 'none', // disables minification for all files
    }
Run Code Online (Sandbox Code Playgroud)

我仍然希望文件包含在最终的合并文件中(与empty: http://requirejs.org/docs/optimization.html#empty不同),只是没有传递给uglify.js

requirejs gruntjs grunt-contrib-requirejs

10
推荐指数
1
解决办法
4177
查看次数

[attribute~ = value]和[attribute*= value]之间的区别

我找不到这两个选择器之间的区别.两者似乎都做同样的事情,即根据包含给定字符串的特定属性值选择标签.

对于[attribute~=value]:http://www.w3schools.com/cssref/sel_attribute_value_contains.asp

对于[attribute*=value]:http://www.w3schools.com/cssref/sel_attr_contain.asp

css css-selectors

8
推荐指数
2
解决办法
1865
查看次数

将多个打字稿文件合并到一个打字稿定义文件中

我需要这个用于在单个文件中分发TypeScript中的库.有没有办法将多个打字稿文件合并到(一个js文件+一个打字稿定义)文件中?

typescript

8
推荐指数
1
解决办法
4603
查看次数

无类型变量对对象有什么好处?null和undefined有什么区别?

根据这个:http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f9f.html Quote:

无类型变量与Object类型的变量不同.关键的区别在于,无类型变量可以保持特殊值undefined,而Object类型的变量不能保存该值.

但是,当我测试它时:


            var objTest:Object = 123;           
            var untypedTest:* = 123;

            objTest = undefined;
            untypedTest = undefined;            
            //This is understandable but why was the assignment even allowed?
            trace(objTest); // prints null
            trace(untypedTest); // prints undefined

            objTest=null;
            untypedTest = null;         
            //This is also understandable ... both can store null 
            trace(objTest); // prints null 
            trace(untypedTest); // prints null 

            //If they are null whey are they being equal to undefined? 
            if(objTest==undefined)
                trace("obj is undefined");
            if(untypedTest==undefined)
                trace("untyped is undefined");
            //Because …
Run Code Online (Sandbox Code Playgroud)

apache-flex flash actionscript actionscript-3

7
推荐指数
1
解决办法
330
查看次数

为什么svg的包含div占用更多空间

这个简单的html:

<div style="background:blue">
  <svg width="40" height="40" style="background:red"></svg> some text
</div>
Run Code Online (Sandbox Code Playgroud)

你可以看到svg是,40px但周围的div 44px很高(在chrome上测试).

为什么.如何使周围的div尊重SVG的大小而不height在周围的div上显式并将布局保持在svg+text一行中?

html css svg

7
推荐指数
1
解决办法
1208
查看次数

用RavenDb查询字典

我有一个类定义为:

public class Student
{
    public string Id { get; set; }
    public IDictionary<string, string> Attributes { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

基于我在此处发现的讨论:http://groups.google.com/group/ravendb/browse_thread/thread/88ea52620021ed6c?pli = 1

我可以很容易地存储一个实例:

//creation
using (var session = store.OpenSession())
{               
    //now the student:
    var student = new Student();
    student.Attributes = new Dictionary<string, string>();

    student.Attributes["NIC"] = "studentsNICnumberGoesHere";               
    session.Store(student);
    session.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)

但是,当我查询如下:

//Testing query on attribute
using (var session = store.OpenSession())
{
    var result = from student in session.Query<Student>()
                 where
                     student.Attributes["NIC"] == "studentsNICnumberGoesHere"
                  select student;

    var test …
Run Code Online (Sandbox Code Playgroud)

ravendb

6
推荐指数
1
解决办法
1668
查看次数

如何更改我的Windows 8发布者显示名称?

我有一个注册的Windows 8开发人员帐户.我没有发布任何应用程序或发送事件进行测试.我可以更改我原先要求的出版商名称吗?

windows-8

6
推荐指数
1
解决办法
3438
查看次数